/*
 * $Id: JMapPropertiesDialog.java 52 2010-01-11 01:42:30Z aaron.day $
 */
package org.crazydays.gameplan.map.swing;


import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.GroupLayout.Alignment;

import org.crazydays.gameplan.map.IGameMap;

/**
 * JMapPropertiesDialog
 */
public class JMapPropertiesDialog
    extends JDialog
{
    /** serial version uid */
    public final static long serialVersionUID =
        "$Id: JMapPropertiesDialog.java 52 2010-01-11 01:42:30Z aaron.day $"
            .hashCode();

    /** game map */
    protected IGameMap gameMap;

    /** apply */
    protected JButton apply;

    /** save */
    protected JButton save;

    /** cancel */
    protected JButton cancel;

    /**
     * JMapPropertiesDialog constructor.
     * 
     * @param gameMap Game map
     */
    public JMapPropertiesDialog(IGameMap gameMap)
    {
        setGameMap(gameMap);
        initialize();
    }

    /**
     * Initialize map properties dialog.
     */
    protected void initialize()
    {
        initializeApplySaveCancel();
        initializeLayout();
        pack();
    }

    /**
     * Initialize apply, save, and cancel buttons.
     */
    protected void initializeApplySaveCancel()
    {
        apply = new JButton("Apply");
        save = new JButton("Save");
        cancel = new JButton("Cancel");
    }

    /**
     * Initialize component layout.
     */
    protected void initializeLayout()
    {
        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);

        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);

        // horizontal
        GroupLayout.SequentialGroup horizontal = layout.createSequentialGroup();

        // TODO:
        horizontal.addGroup(layout.createParallelGroup().addComponent(apply));
        horizontal.addGroup(layout.createParallelGroup().addComponent(save));
        horizontal.addGroup(layout.createParallelGroup().addComponent(cancel));

        layout.setHorizontalGroup(horizontal);

        // vertical
        GroupLayout.SequentialGroup vertical = layout.createSequentialGroup();

        // TODO:
        vertical.addGroup(layout.createParallelGroup(Alignment.BASELINE)
            .addComponent(apply).addComponent(save).addComponent(cancel));

        layout.setVerticalGroup(vertical);
    }

    /**
     * Set game map.
     * 
     * @param gameMap Game map
     */
    public void setGameMap(IGameMap gameMap)
    {
        this.gameMap = gameMap;
    }

    /**
     * Get game map.
     * 
     * @return Game map
     */
    public IGameMap getGameMap()
    {
        return gameMap;
    }
}
